<?php
$link = mysql_connect("localhost","root","");
mysql_select_db("inventario",$link);
if ($boton == "Cerrar Transaccion"){
   $sql ="update movimientos set tipo=2 where Numero='$NumMov'";
   $result = mysql_query($sql,$link);
   $sql ="Select * from movimientos where Numero='$NumMov'";
   $result = mysql_query($sql,$link);
   while ($row = mysql_fetch_array($result)){
      $sql2 ="Select * from productos where codigo='".$row["codigo"]."'";
      $result2 = mysql_query($sql2,$link);
      $row2 = mysql_fetch_array($result2);
      $Stock = intval($row2["Stock"])+intval($row["cantidad"]);
      $sql2 ="Update productos set Stock=$Stock where id=".$row2["id"];
      $result2 = mysql_query($sql2,$link);
   }
}
header("location: ../../index.php?psa_modulo=$psa_modulo");
?>